﻿using System;
using System.Linq;
using Microsoft.Practices.ObjectBuilder2;
using Sharp.Infrastructure;
using Sharp.Infrastructure.Crosscutting;
using Sharp.Infrastructure.Interfaces;
using Sharp.Infrastructure.IoC;

namespace Sharp.Services.CMS
{
    public class PreWarmUp : System.Web.Hosting.IProcessHostPreloadClient
    {
        public void Preload(string[] parameters)
        {
            var bootstraps = ServiceLocator.Instance.GetServiceAll<IBootstrapPlugin>().ToArray();
            bootstraps.ForEach(x =>
            {
                if(!x.IsAlready)
                    x.Initialize();
            });
            LogHelper.Verbose(DateTime.Now + "开始预热。");
        }
    }
}